// component/microPage/custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // selected:{  // 接收页面传入的数据
    //   type:String,
    //   value:'1'
    // },
  },
  /**
   * 组件的初始数据
   */
  data: {
    selected: 0,
    color: "#333333",
    selectedColor: "#ec0e0e",
    list: [
      {
        "pagePath": "/pages/home/home",
        "iconPath": "/image/home.png",
        "selectedIconPath": "/image/home_red.png",
        "cssStyle":"",
        "txtCss":"",
        "text": "首页"
      },
      {
        "pagePath": "/pages/property/index",
        "iconPath": "/image/service.png",
        "selectedIconPath": "/image/service_red.png",
        "cssStyle":"",
        "txtCss":"",
        "text": "服务"
      },
      {
        "pagePath": "/pages/smallPage/index",
        "iconPath": "/image/area.png",
        "selectedIconPath": "/image/area_red.png",
        "cssStyle":"",
        "txtCss":"",
        "text": "商圈"
      },
      {
        "pagePath": "/pages/personal/index",
        "iconPath": "/image/my.png",
        "selectedIconPath": "/image/my_red.png",
        "cssStyle":"",
        "text": "我的"
      }  
    ]
  },

  attached() {},
  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      console.log('switchTab',e)
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({
        url,
        success: (res) => {
          console.log('wx.switchTab',res)
          let page = getCurrentPages().pop();
          if (page == undefined || page == null) return;
          page.onLoad()
        }
      })
      this.setData({
        selected: data.index
      })
    }
  },
})
